<!DOCTYPE html>
<html>
 <head>
  <title>
   Download Data via PixieDust
  </title>
  <meta content="&#xA9;Copyright IBM Corporation 2018" name="copyright"/>
  <meta content="&#xA9;Copyright IBM Corporation 2018" name="DC.Rights.Owner"/>
  <meta content="&#xA9; Copyright IBM Corporation 2016, 2017, 2018" name="dcterms.rights"/>
  <meta content="2018-03-09" name="DC.date"/>
 </head>
 <body>
  <div>
   <h1>
    Download Data via PixieDust
   </h1>
   <p>
    PixieDust lets you download the data from your notebook. If you've been playing with some charts, you can also save and download in SVG format.
   </p>
   <div>
    <h1>
     Save data to a file
    </h1>
    <p>
     You can save a data set to a number of different file formats, including CSV, JSON, XML, and more. You do so within the user interface controls that the display API generates.
     <a href="displayapi.html">
      Read how to run and work with display()
     </a>
     .
    </p>
    <ol>
     <li>
      <p>
       Above the table and charts display, click the Download dropdown arrow. You see the following menu:
      </p>
      <img alt="_images/downloadfile.png" src="https://raw.githubusercontent.com/ibm-watson-data-lab/pixiedust/master/docs/_images/downloadfile.png"/>
     </li>
     <li>
      <p>
       Choose
       <strong>
        Download as File
       </strong>
       Choose the format you want, and specify the number of records to download.
      </p>
      <img alt="_images/save_as.png" src="https://raw.githubusercontent.com/ibm-watson-data-lab/pixiedust/master/docs/_images/save_as.png"/>
     </li>
     <li>
      <p>
       Click
       <strong>
        OK
       </strong>
       .
      </p>
     </li>
    </ol>
   </div>
   <div>
    <h1>
     Export data to Cloudant
     <sup>
      BETA
     </sup>
    </h1>
    <p>
     PixieDust also lets you save directly to a Cloudant database.
    </p>
    <ol>
     <li>
      <p>
       Above the table and charts display, click the Download dropdown arrow. You see the following menu:
      </p>
      <img alt="_images/downloadfile.png" src="https://raw.githubusercontent.com/ibm-watson-data-lab/pixiedust/master/docs/_images/downloadfile.png"/>
     </li>
     <li>
      <p>
       Choose
       <strong>
        Stash to Cloudant
       </strong>
       .
      </p>
     </li>
     <li>
      <p>
       To the right of the
       <strong>
        Cloudant Connection
       </strong>
       field, click the + plus button.
      </p>
     </li>
     <li>
      <p>
       Enter your Cloudant database credentials and click
       <strong>
        OK
       </strong>
       .
      </p>
     </li>
    </ol>
    <blockquote>
     <strong>
      Note
     </strong>
     <p>
      If you get a
      <strong>
       Too many requests
      </strong>
      error, you are on the Cloudant Lite plan. The only way to raise limits, is to upgrade your Cloudant plan.
     </p>
    </blockquote>
    <blockquote>
     <strong>
      Note
     </strong>
     <p>
      If you get an error that a library is missing, install the cloudant-spark library. This is a manual one-time step that requires a kernel restart. Download the cloudant-spark jar for your Spark version.
     </p>
     <!-- START EXCLUDE -->
     <p>
      For Spark 1.6:
      <code>
       <span>
        https://github.com/cloudant-labs/spark-cloudant/releases/download/v1.6.4/cloudant-spark-v1.6.4-167.jar
       </span>
      </code>
      ...
     </p>
     <!-- END EXCLUDE -->
     <p>
      For Spark 2.0:
      <code>
       <span>
        https://github.com/cloudant-labs/spark-cloudant/releases/download/v2.0.0/cloudant-spark-v2.0.0-185.jar
       </span>
      </code>
     </p>
     <p>
      Then create a directory named
      <cite>
       jars
      </cite>
      under the home directory with
      <code>
       mkdir jars
      </code>
      . Copy the cloudant-spark jar file into the newly created directory. Then locate kernel.json file under the directory listing by running command
      <code>
       jupyter pixiedust list
      </code>
      . Edit kernel.json file and update the variable PYSPARK_SUBMIT_ARGS under env by adding --jars &lt;local_home_directory&gt;/jars/cloudant-spark.jar.
      <code>
       "PYSPARK_SUBMIT_ARGS":
       <span>
        "--jars
       </span>
       <span>
        /Users/USERNAME/jars/cloudant-spark-v1.6.4-167.jar
       </span>
       <span>
        ....
       </span>
      </code>
     </p>
    </blockquote>
   </div>
   <div>
    <h1>
     Save a chart or map in SVG format
    </h1>
    <p>
     If you've created a sweet chart that you want to save, click the
     <strong>
      Download SVG
     </strong>
     button.
    </p>
    <p>
     Install cloudant-spark library
    </p>
    <p>
     You can export the data to a Cloudant database. A supporting library cloudant-spark jar is required for the export.
This is a manual one-time step that requires a kernel restart. Download cloudant-spark jar file for respective Spark version from:
    </p>
    <!-- START EXCLUDE -->
    <pre>Spark 1.6: https://github.com/cloudant-labs/spark-cloudant/releases/download/v1.6.4/cloudant-spark-v1.6.4-167.jar</pre>
    <!-- END EXCLUDE -->
    <pre>Spark 2.0: https://github.com/cloudant-labs/spark-cloudant/releases/download/v2.0.0/cloudant-spark-v2.0.0-185.jar</pre>
    <p>
     Create a directory of your choice for example jars under the home directory.
    </p>
    <pre>mkdir jars</pre>
    <p>
     Copy the cloudant-spark jar file into the newly created directory.
    </p>
    <p>
     Locate kernel.json file under the directory listing by running command.
    </p>
    <pre>jupyter pixiedust list</pre>
    <p>
     Edit kernel.json file and update the variable PYSPARK_SUBMIT_ARGS under env by adding --jars &lt;local_home_directory&gt;/jars/cloudant-spark.jar.
    </p>
    <pre>"PYSPARK_SUBMIT_ARGS": "--jars /Users/USERNAME/jars/cloudant-spark-v1.6.4-167.jar ....</pre>
   </div>
   <p>
    <h3>
     Return to main topic for:
    </h3>
    <ul>
     <li>
      <a href="use.html">
       Use PixieDust
      </a>
     </li>
    </ul>
   </p>
  </div>
 </body>
</html>
